package com.example.cnedujnux2022100602

import androidx.compose.ui.test.*
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

/**
 * Instrumented test, which will execute on an Android device.
 *
 * See [testing documentation](http://d.android.com/tools/testing).
 */
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
    @get:Rule
    val composeTestRule = createComposeRule()

    @Test
    fun testMainScreen() {
        // 启动主界面
        composeTestRule.setContent {
            MainScreen()
        }

        // 测试输入框
        composeTestRule.onNodeWithText("输入文本").assertExists()
        
        // 输入文本
        composeTestRule.onNodeWithText("输入文本").performTextInput("测试文本")
        
        // 点击按钮
        composeTestRule.onNodeWithText("显示文本").performClick()
        
        // 验证显示文本
        composeTestRule.onNodeWithText("测试文本").assertExists()
    }
}